<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" %>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Debit Note Register</title>
</head>
<body>
<center><h2> Debit Note Register </h2> </center>

<form action="DebitPeriodicServlet">

  <%
        String exportToExcel = request.getParameter("exportToExcel");
        if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) 
        {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "inline; filename=" + "DebitNoteReport.xls");
 
        }
    %>

<table border=1 align="center"> 

<tr>
	<th>Invoice Number</th>
	<th>Date</th>
	<th>Supplier Name</th>
	<th>Supplier Code</th>
	<th>Product Name</th>
	<th>Product Quantity</th>
	<th>Product Rate</th>
	<th>Net Amount</th>
	<th>Taxation Category</th>
	<th>Tax Amount</th>
	<th>Transport Charges</th>
	<th>Other Costs</th>
	<th>Total Amount</th>
	<th>Rejection Reason </th>
	<th>Credit Limit</th>
</tr>

		<%  DBConnection dbc=new DBConnection();
			Connection con=dbc.getNewConnection();
			Statement st = null;
			ResultSet rs = null;
			
			double d8=0.0,d10=0.0,d11=0.0,d12=0.0,d13=0.0;
			
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select * from DebitNote where status=1"); %>
	        	
       		 <%  while(rs.next()){ %>
<tr>
					<td><%= rs.getString(1)%></td>
            		<td><%= rs.getString(2)%></td>
            		<td><%= rs.getString(3)%></td>
            		<td><%= rs.getString(4)%></td>
            		<td><%= rs.getString(5)%></td>
 					<td><%= rs.getDouble(6)%></td>
 					<td><%= rs.getDouble(7)%></td>
 					           		
            		<% double v8=rs.getDouble(8); %>         		
            		<td><%=v8 %></td>
            		<td><%= rs.getDouble(9)%></td>
            		
            		<% double v10=rs.getDouble(10); %>         		
            		<td><%=v10 %></td>
            		
					<% double v11=rs.getDouble(11); %>         		
            		<td><%=v11 %></td>
            		
            		<% double v12=rs.getDouble(12); %>         		
            		<td><%=v12 %></td>
            		
            		<% double v13=rs.getDouble(13); %>         		
            		<td><%=v13 %></td>
            		<td><%= rs.getString(14)%></td>
            		<td><%= rs.getInt(15)%></td>
            		
</tr>
        		<% 
        			d8=d8+v8;
        			d10=d10+v10;
        			d11=d11+v11;
        			d12=d12+v12;
        			d13=d13+v13;
        			       		 
       		 } %>
  
	 		<% }
			catch(Exception e){} %>


<tr>
	<td> <b> Total </b></td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> <%=d8 %></td>
	<td> </td>
	<td> <%=d10 %></td>
	<td> <%=d11 %></td>
	<td> <%=d12 %> </td>
	<td> <%=d13 %></td>
	<td> </td>
	<td> </td>
	
</tr>	
			
</table><br>
<br>
From <input type="text" name="fromdate"/> To <input type="text" name="todate" /><input type="submit" value="Generate"/>

<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


    <%
        if (exportToExcel == null) {
    %>
    <a href="DebitNoteReport.jsp?exportToExcel=YES">Export to Excel</a>
    <%
        }
    %>
</form>

<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<form name="delete_form" action="DebitNoteDeleteServlet">
<input type="text" name="delete"> 
<input type="submit" value="Delete Voucher">

<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://localhost:8081/BOA_Web/DeletedDebitNotes.jsp">Deleted Debit Notes</a>

<center><input type="button" value="Print this page" onClick="window.print()"></center>

</form>

</body>
</html>